<!--
 * @Description: 
 * @Author: mmzhang
 * @Date: 2022-11-14 10:12:04
 * @LastEditTime: 2023-01-10 16:08:42
-->
<template>
  <div>
    <dt-modal-info ref="info" title="流程信息" :width="800">
      <dt-grid ref="table" :columns="columns" :list="list" height-resize />
    </dt-modal-info>

    <preview-image ref="previewImage" :images="images" showDownLoad />
    <transfer-modal ref="transfer" @success="process" />
  </div>
</template>

<script>
  import columnOpt from './opt/processColumn.js'
  import auditMgr from '@/biz/flowApproval/processAudit.js'
  import transferModal from './transfer-modal.vue'

  export default {
    components: { transferModal },
    data() {
      return {
        info: {
          auditId: '',
          auditType: '',
          businessId: ''
        },
        columns: [],
        list: [],
        images: [],
        isShowImg: false
      }
    },
    methods: {
      show(data) {
        console.log('auditInfo----', data)
        this.info = data
        //置业计划书需要展示图片信息
        this.isShowImg = this.info.auditType == 13 ? true : false
        this.$refs.info.show()
        this.columns = columnOpt.options(this, true)
        this.$refs.table.init(this)
        this.process()
      },
      hide() {
        this.$refs.info.hide()
      },
      process() {
        auditMgr
          .process({
            auditType: this.info.auditType,
            businessId: this.info.businessId
          })
          .then((res) => {
            let cur = res.find((i) => !i.operateDate)
            this.list = res.map((i) => ({
              ...i,
              canRefer: this.info.auditState == 'APPROVAL' && cur && i.id == cur.id ? true : false
            }))
          })
      },
      onRefer(item) {
        this.$refs.transfer.show({
          auditId: this.info.auditId
        })
      },
      onImage(item) {
        this.images = JSON.parse(item.auditFile).annexList
        this.$refs.previewImage.show()
      }
    }
  }
</script>

<style lang="scss" scoped></style>
